package com.lww.feature.test.io.pipe;

import java.io.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * author: liweiwei
 * Date: 2018/12/26
 */
public class StreamOpExclusion {

    public static void main(String[] args) throws IOException {
        File file = new File("/Users/lww/IdeaProjects/code/myproject/test/src/main/java/com/lww/feature/test/io/pipe/test.txt");
//        FileInputStream fileInputStream = new FileInputStream(file);
//        FileInputStream fileInputStream2 = new FileInputStream(file);
        FileOutputStream fileOutputStream = new FileOutputStream(file);

        ExecutorService executorService = Executors.newFixedThreadPool(9);
        executorService.submit(()->{
            try {
                fileOutputStream.write(1);
                fileOutputStream.flush();
                System.out.println("inend");
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
        fileOutputStream.write(2);
        fileOutputStream.flush();


        System.out.println("outend");
    }
}
